package com.lihao.sam.controller;

import com.lihao.sam.entity.CollegeSetting;
import com.lihao.sam.entity.Company;
import com.lihao.sam.service.intf.CollegeSettingService;
import com.lihao.sam.service.intf.CompanyService;
import com.lihao.sam.vo.PageVo;
import com.lihao.sam.vo.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Author LiHao
 * @Description CollegeSettingController
 * @Date 13:10 2022/11/22
 */
@RestController
@RequestMapping("/api/college/")
public class CollegeSettingController {
    @Resource
    private CollegeSettingService service;

    @PostMapping("add.do")
    public R add(CollegeSetting collegeSetting) {
        return service.add(collegeSetting);
    }

    @PostMapping("update.do")
    public R update(CollegeSetting collegeSetting) {
        return service.update(collegeSetting);
    }

    @PostMapping("delete.do")
    public R delete(int id, HttpSession session) {
        return service.delete(id);
    }

    @PostMapping("deletebatch.do")
    public R deleteBatch(int[] ids) {
        return service.deleteBatch(ids);
    }
    @GetMapping("page.do")
    public PageVo page(int page, int limit, String collegeName, String deptName, String major) {
        return service.queryPage(page, limit, collegeName, deptName, major);
    }

    @PostMapping("upload.do")
    public R upload(MultipartFile file) throws IOException {
        return service.uploadExcel(file);
    }

    @GetMapping("download.do")
    public void download(HttpServletResponse response) throws IOException {
        service.download(response);
    }

    @GetMapping("collegemajorcount.do")
    public R collegeMajorCount(){
        return service.queryCollegeMajorCount();
    }
}
